<script>
    $().ready(function(){          
        $('.txt_active').change(function(){
           var bien = $(this).val();  
           var id = $(this).attr('id');
           var commentContainer = $(this).parent();
           $('.load').html('<img src="<?php echo base_url()?>public/images/loading.gif" />');          
           $.ajax({
                type : "POST",
                dataType : "json",
                url : "<?php echo base_url().'admin/order/update'?>",
                data: 'type=' + bien  + '&id=' + id,               
                success : function(result){                   
                     $('.load').html('');          
                     alert(result.status);                     
                     return false;                     
                }               
           });
         
        });  
       /*$('.delete').click(function(){        
        var id = $(this).attr('id');
               if(confirm('Bạn có mún xóa không ?'))
               {
                $.ajax({
                    type : "GET",
                    dataType : "html",
                    url : "<?php echo base_url().'admin/order/delete_order'?>",
                    data : 'id=' + id,
                    success : function(result){                          
                        
                         return true;
                    }
                });               
               } 
               else
               {
                return false;
               }
        });   */  
        $(".edit").fancybox({
        	'scrolling'		: 'no',
        	'titleShow'		: false,
        	'onClosed'		: function() {
        	    $("#login_error").hide();
        	}
        });
        $('.edit').click(function(){
          
        var id = $(this).attr('id');               
                $.ajax({
                    type : "GET",
                    dataType : "html",
                    url : "<?php echo base_url().'admin/order/get_id'?>",
                    data : 'id=' + id,
                    success : function(result){                          
                        $.fancybox(data); 
                         
                    }
                });          
               return false;
        });
       
    });
    
</script>
<div id="box"></div>
<div class="load" style="position: absolute; top: 262px;  left:425px; z-index:9999"></div>
<div class="info">
<h1 class="font_h1">Danh sách Đơn hàng</h1>
<?php if(isset($error))  : ?>
<h2 class="error_red"><?php echo $error;?></h2>
<?php endif;?>
<table cellpadding="0" cellspacing="0" style="background:#FFF; color:#000;">
        <tr class="tr">
        	<td><input type="checkbox" value=""></td>        	
            <td>Tên khách hàng</td>             
            <td>Sản phẩm</td>
            <td>Số lượng</td>  
            <td>Trạng thái</td>         
            <td colspan="2">Hành động</td>            
        </tr>
        <?php foreach($list_order as $row) : ?>
        <tr id="aa" style="text-align:center">
        	<td><input type="checkbox" id="<?php echo $row->id_order;?>" class="<?php echo $row->id_order;?>" value="<?php echo $row->id_order;?>"></td>   
        	<td><?php echo $row->fullname;?></td>
            
            <td><?php echo $this->product_model->get_name_product($row->id_product);?></td>
            <td><?php echo $row->soluong;?></td>
            <td>
            <select class="txt_active" id="<?php echo $row->id_order;?>" style="width:120px">
            	<option value="1"<?php if($row->active == '1') echo "selected";?>>Hiển thị</option>
                <option value="0"<?php if($row->active == '0') echo "selected";?>>Không hiện thị</option>
            </select>
           
            <td>
            	<a href="<?php echo base_url().'admin/order/get_id/'.$row->id_order?>" title="Edit" class="edit" id="<?php echo $row->id_order;?>"><img src="<?php echo base_url()?>public/admin/images/user_edit.png"></a>
                &nbsp;&nbsp;
                <a href="<?php echo base_url().'admin/order/delete_order/'.$row->id_order?>" title="Delete" id="<?php echo $row->id_order;?>"><img src="<?php echo base_url()?>public/admin/images/trash.png"></a>
            </td>
        </tr>
        <?php endforeach ; ?>
      
        

</table>
</form>
<a href="" class="button">Xóa bản tin đã chọn</a>


</div>

